﻿@using System.Globalization
@using RBS.Common
@model IEnumerable<RBS.Core.Model.SYS_Navigation>

@{
    ViewBag.Title = "NavManage";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script>
    $(function() {
        $("#btnDelete").click(function () { 
            $.dialog.confirm("本操作会删除本导航及下属子导航，是否继续？", function () {
                var f_str="";
                $(".ltable :checkbox[name='chkId']").each(function () {
                    if (this.checked && this.value!="undefined") {
                         f_str+= this.value + ',';
                        //alert(this.value); 
                        var datas = "{ids:'" + f_str + "'}";
                        var url = '@Url.Action("NavDelete")?ids=' + f_str;
                         $.ajax({
                             url: url,
                             type: "post",
                             dataType: 'json', 
                             success: function (data) {
                                 if (data.IsSuccess) {
                                     loadPage(data.Data);
                                 }
                                 else {
                                   //  $("#msgtip").text(data.Msg);
                                     $.dialog.alert(data.Msg);
                                 }
                             }
                         });
                    }
                });
               
            });
            return false;
        });
    });
</script>
<!--导航栏-->
<div class="location">
    <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
    <a href="../center.aspx" class="home"><i></i><span>首页</span></a>
    <i class="arrow"></i>
    <span>后台导航管理</span>
</div>
<!--/导航栏-->

<!--工具栏-->
<div class="toolbar-wrap">
    <div id="floatHead" class="toolbar">
        <div class="l-list">
            <ul class="icon-list">
                <li><a class="add" href="NavCreate?id=0"><i></i><span>新增</span></a></li> 
                <li><a class="all" href="javascript:;" onclick="checkAll(this);"><i></i><span>全选</span></a></li>
                <li>
                    <a class="del" href="#" id="btnDelete"><i></i><span>删除</span></a>
                    
                </li>
            </ul>
        </div>
    </div>
</div>
<!--/工具栏-->
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
    <tr>
        <th width="8%">选择</th>
        <th align="left" width="12%">调用ID</th>
        <th align="left">导航标题</th>
        <th width="8%">显示</th>
        <th width="8%">默认</th>
        <th align="left" width="65">排序</th>
        <th width="12%">操作</th>
    </tr>

    @foreach (var item in Model)
    { 
        <tr>
            <td align="center">
                @if (item.is_sys == 0)
                {
                    <input type="checkbox" id="chkId" name="chkId" class="checkall" navId="@item.id" value="@item.id" style="vertical-align: middle;" />
                }
                <input type="hidden" ID="hidId" Value='@item.id'  />
                <input type="hidden" ID="hidLayer" Value='@item.class_layer'   />
            </td>
            <td style="white-space: nowrap; word-break: break-all; overflow: hidden;">@Html.DisplayFor(modelItem => item.name)</td>
            <td style="white-space: nowrap; word-break: break-all; overflow: hidden;">
                @{
                string LitStyle = "<span style=\"display:inline-block;width:{0}px;\"></span>{1}{2}";
                string LitImg1 = "<span class=\"folder-open\"></span>";
                string LitImg2 = "<span class=\"folder-line\"></span>";
                string LitFirst = "";
                if (@item.class_layer == 1)
                {
                    LitFirst = LitImg1;
                }
                else
                {
                    LitFirst = string.Format(LitStyle, (@item.class_layer - 2) * 24, LitImg2, LitImg1);
                } 
                }
                @Html.Raw(LitFirst)
                @Html.ActionLink(@item.title, "Edit", new { id = item.id, type = RBSEnums.ActionEnum.Edit })
                @(item.link_url.ToString(CultureInfo.InvariantCulture) ?? "")
            </td>
            <td align="center">
                @(item.is_lock == 0 ? "是" : "否")
            </td>
            <td align="center">
                @(item.is_sys == 1 ? "是" : "否")
            </td>
            <td>
                <input  ID="txtSortId" type="text" value='@item.sort_id' class="sort" onkeydown="return checkNumber(event);" />
            </td>

            <td align="center" style="white-space: nowrap; word-break: break-all; overflow: hidden;">
                @Html.ActionLink("添加子级", "NavCreate", new { id = item.id})
                @Html.ActionLink("修改", "NavEdit", new { type = RBSEnums.ActionEnum.Edit,id = item.id  })
            </td>
        </tr>
  
    }

</table>
